/**
 * @version Create on 2012-11-11
 * @author Yinzi Chen
 */

public class MinimumDepthOfBinaryTree {

	class TreeNode {
		int val;
		TreeNode left;
		TreeNode right;

		TreeNode(int x) {
			val = x;
		}
	}

	public int getDepth(TreeNode root) {
		if (root == null)
			return 0;
		int min = Integer.MAX_VALUE;
		if (root.left != null)
			min = Math.min(min, getDepth(root.left) + 1);
		if (root.right != null)
			min = Math.min(min, getDepth(root.right) + 1);
		if (min == Integer.MAX_VALUE)
			min = 1;
		return min;
	}

	public int minDepth(TreeNode root) {
		return getDepth(root);
	}

	public static void main(String[] args) {

	}

}
